<template>
  <div class="information_content">
    <ul>
      <router-link
        :to="{
        name:'/AdvisoryDetails',
        params:{
          id : List.id
        }
      
      }"
        v-for=" List  in contentList"
        :key="List.id"
        tag="li"
      >
        <div class="content_left">
          <h4>{{List.title}}</h4>
          <div class="content">{{List.content}}</div>
          <div class="tyle_item">
            <div class="tyle">
              #{{tyles == "0" ? "热门推荐"
              : tyles == "1" ? "独家解析"
              : tyles == "2" ? "资讯头条"
              : tyles == "3" ? "报考指南"
              : tyles == "4" ? "报考经验"
              : tyles == "5" ? "政策解读"
              :" "}}
            </div>
            <div class="item">{{List.createTime}}</div>
          </div>
        </div>
        <div class="content_right">
          <img :src="List.picOne" alt />
        </div>
      </router-link>
    </ul>

    <h2 @click="page">查看更多</h2>
  </div>
</template>
<script>
export default {
  name: "Content",
  props: ["tyles"],
  data() {
    return {
      contentList: [],
      pageNows: 0
    };
  },
  beforeCreate() {
    this.$nextTick(() => {
      let types = this.$props.tyles;
      console.log(this.$props.tyles);
      this.getList();
    });
  },

  methods: {
    getList() {
      let types = this.$props.tyles;
      let pageNows = this.pageNows;
      this.$ajax({
        method: "post",
        url: "/api/piccontent/list",
        data: {
          pageNow: 1,
          pageSize: 3 + pageNows,
          type: types
        },

        success: res => {
          if (res.data.code == 0) {
            this.contentList = res.data.data.list;
          }
        }
      });
    },
    page() {
      this.pageNows += 10;
      let pageNows = this.pageNows;
      let types = this.$props.tyles;
      this.$ajax({
        method: "post",
        url: "/api/piccontent/list",
        data: {
          pageNow: 1,
          pageSize: 3 + pageNows,
          type: types
        },

        success: res => {
          if (res.data.code == 0) {
            this.contentList = res.data.data.list;
          }
        }
      });
    }
  }
};
</script>


<style lang="scss">
.information_content {
  h2 {
    text-align: center;
    padding: 32px 0;
    color: #959595;
    font-size: 18px;
    cursor: pointer;
  }
  ul {
    li {
      background: #f0f0f0;
      display: flex;
      justify-content: space-between;
      padding: 28px 72px;
      margin-bottom: 24px;
      border-radius: 3px;
      .content_left {
        margin-top: 12px;
        h4 {
          color: #414141;
          line-height: 42px;
          font-size: 20px;
        }
        .content {
          width: 830px;
          color: #757575;
          font-size: 14px;
          line-height: 20px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
        }
        .tyle_item {
          display: flex;
          justify-content: space-between;
          width: 318px;
          padding: 40px 0;
          font-size: 12px;
          color: #8a8a8a;
        }
      }
      .content_right {
        img {
          width: 172px;
          height: 172px;
          border-radius: 6px;
        }
      }
    }
  }
}
</style>